angular.module("projectstart.service", [])
    .factory('projectstart_Service',['$http',function($http){
        var service = {};

        //获取所有的产品信息
        service.allprojectsGet = function () {
            return $http({
                method: 'GET',
                url: "/api/project/getAllProduct"
            });
        };

        //获取所有的项目经理信息
        service.allPMsGet = function () {
            return $http({
                method: 'GET',
                // url: "/api/projectstart/getAllPMs"
                url:"/api/project/getAllPeople"
            });
        };

        //获取所有的部署经理信息
        service.allDMsGet = function () {
            return $http({
                method: 'GET',
                // url: "/api/projectstart/getAllDMs"
                url:"/api/project/getAllPeople"
            });
        };

        //根据选中的产品ID获取每个产品对应的开发人员信息(入参是选中添加的产品列表)
        service.allCodersGet = function (data) {
            return $http({
                method: 'POST',
                // url: "/api/projectstart/getAllCoders",
                url:"/api/project/getPeopleForProduct",
                data: JSON.stringify(data),
                dataType:"application/json"
            });
        };

        //根据选中的产品ID获取每个产品对应的测试人员信息(入参是选中添加的产品列表)
        service.allTestersGet = function (data) {
            return $http({
                method: 'POST',
                // url: "/api/projectstart/getAllTesters",
                url:"/api/project/getPeopleForProduct",
                data: JSON.stringify(data),
                dataType:"application/json"
            });
        };

        //保存项目信息
        service.newProjectSave = function (data) {
            return $http({
                method: 'POST',
                url: "/api/project/save",
                data: JSON.stringify(data),
                dataType:"application/json"
            });
        };

        //保存项目信息
        service.getProject = function (data) {
            return $http({
                method: 'GET',
                url: "/api/project/get",
                params: {"projectId":data},
                dataType:"application/json"
            });
        };

        //保存项目信息
        service.findProject = function (data) {
            return $http({
                method: 'GET',
                url: "/api/project/find",
                params:{"keyword":data.keyword},
                dataType:"application/json"
            });
        };

        //保存（修改）流水线配置的接口
        service.savePipeLineConfig = function (data) {
            return $http({
                method: 'POST',
                url: "/api/project/savePipeLineConfig",
                data: JSON.stringify(data),
                dataType:"application/json"
            });
        };

        //根据项目ID获取该项目的流水线配置信息的接口
        service.getPipeLineConfig = function (data) {
            return $http({
                method: 'GET',
                url: "/api/project/getPipeLineConfig",
                params:{"projectId":data.projectId},
                dataType:"application/json"
            });
        };

        //根据projectId删除项目配置
        service.deleteProject = function (data) {
            return $http({
                method: 'GET',
                url: "/api/project/deleteProject",
                params:{"projectId":data.projectId},
                dataType:"application/json"
            });
        };

        return service;
    }]);